/*! \if exist This is -*- C++ -*- from nbg \endif

    \file  Main.h
    \brief Driver (main program) for command line-based usage of ARFFHandler lib.

    Basic function: Parse command parameter for supported functionality (currently:
    copy ARFF file, show content, remove single features, split ARFF file with
    multiple classes into multiple files with a single class each), then parse
    the required parameters for these diverse functions.

    \par Last Author: Martin Loesch (<professional@@martinloesch.net>)
    Date of last change: 11.06.13

    \author   Martin Loesch (<loesch@@ira.uka.de>)
    \date     2009-11-26
    \par Copyright:
              Martin Loesch, Chair Prof. Dillmann (IAIM)\n
              Institute for Computer Science and Engineering (CSE)\n
	      University of Karlsruhe. All rights reserved\n
	      http://wwwiaim.ira.uka.de
*/

#ifndef MAIN_H
#define MAIN_H

/* system includes */
#include <boost/program_options.hpp>

/* my includes */
/* (none) */

namespace bpo = boost::program_options;
using namespace std;


//! enum for valid operation modes 
typedef enum {
  INVALID,
  COPY,
  SHOW,
  REMFEATURE,
  SPLITCLASSES
} OperationMode;


//! global operation mode
static OperationMode g_mode = INVALID;
//! global name of input file
static std::string g_inputfilename = "";
//! global name of output file
static std::string g_outputfilename = "";
//! global name of chosen single feature
static std::string g_featurename = "";


/*!
  \brief Parse operation mode from a string (= command line parameter).

  @param mode mode as a string
  @return related enum to the input parameter
*/
OperationMode parseOperationMode(string mode);

/*!
  \brief Print usage of the stand-alone activity recognizer to standard out.

  @param progname name of the program that was called
  @param options object containing the allowed options together with their description
*/
void printUsageHint(string progname, bpo::options_description& options);


//@{
//! \name Functions performing commands

/*!
  \brief Perform a copy operation.

  \pre The parameters \em load and \em save must be given. The loaded file is written to the save file.

  @return 0 if everything went right, 1 else
*/
int performCopy();
/*!
  \brief Perform a remove feature operation.

  \pre The parameters \em load and \em feature must be given. The \em save parameter is optional; if it is given, the changed loaded file is written to the save file, otherwise it is written to standard output.

  @return 0 if everything went right, 1 else
*/
int performRemFeature();
/*!
  \brief Perform a show operation.

  \pre The \em load parameter must be given. The loaded files data is written to the standard output.

  @return 0 if everything went right, 1 else
*/
int performShow();

/*!
  \brief Split the data for different classes into single files.

  \pre The parameters \em load and \em save must be given.

  The actual file names are generated by appending the class names to the given save file name.

  @return 0 if everything went right, 1 else
*/
int performSplitClasses();

//@}


//@{
//! \name Functions parsing required command parameters

/*!
  \brief Parse parameters for a copy operation.

  The parameters which are necessary for a copy are a load and at least one save parameter.
  
  @param vm structure containing all parameters
  @return 0 if parsing was successful, 1 if parameters were missing
*/
int processCopyParameters(bpo::variables_map& vm);
/*!
  \brief Parse parameters for a remove feature operation.

  The parameters which are necessary for a feature removal are at least a load and a feature option. If at least one save parameter is given, the resulting arff is written to the file(s), otherwise the changed arff is written to standard out.
  
  @param vm structure containing all parameters
  @return 0 if parsing was successful, 1 if parameters were missing
*/
int processRemFeatureParameters(bpo::variables_map& vm);
/*!
  \brief Parse parameters for a show operation.

  The parameter which is necessary for the show is at least one load parameter.
  
  @param vm structure containing all parameters
  @return 0 if parsing was successful, 1 if parameters were missing
*/
int processShowParameters(bpo::variables_map& vm);

/*!
  \brief Parse parameters for a split classes operation.

  The parameters which are necessary for the split are at least one load parameter and a save parameter.

  @param vm structure containing all parameters
  @return 0 if parsing was successful, 1 if parameters were missing
*/
int processSplitclassParameters(bpo::variables_map& vm);

/*!
  \brief Process command line parameters and make settings accordingly.

  @param argc same name and function as argc in main() routine
  @param argv same name and function as argv in main() routine
*/
void processCommandlineParameters(int argc, char **argv);

//@}

#endif /* MAIN_H */
